package com.jindianjichi.oss.config;
import com.jindianjichi.oss.adapter.AliStorageAdapter;
import com.jindianjichi.oss.adapter.MinioStorageAdapter;
import com.jindianjichi.oss.adapter.StorageAdapter;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@RefreshScope
@Slf4j
public class StorageConfig {

    @Value("${storage.service.type}")
    private String storageType;

    @Bean
    @RefreshScope
    public StorageAdapter storageService() {
        storageType="minio";
        log.info("当前文件存储处理器为:{}", storageType);
        if ("minio".equals(storageType)) {
            return new MinioStorageAdapter();
        } else if ("aliyun".equals(storageType)) {
            return new AliStorageAdapter();
        } else {
            throw new IllegalArgumentException("未找到对应的文件存储处理器");
        }
//        return new MinioStorageAdapter();
    }



}
